package com.cuit.ocp.controller;

import com.cuit.ocp.bean.ReturnOrder;
import com.cuit.ocp.service.ReturnOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@CrossOrigin(origins ="*",maxAge = 3600)
@RestController
@RequestMapping("returnOrder")
public class ReturnOrderController {
    @Resource
    ReturnOrderService returnOrderService;

    @GetMapping("/getAllReturnOrderByPage")
    Map<Object,Object> getAllReturnOrderByPage(@RequestParam(value = "current_page",defaultValue = "1") int current_page){
        Map<Object,Object> result = new HashMap<>();
        result = returnOrderService.getAllReturnOrderByPage(current_page);
        return result;
    }

    @PostMapping("/addReturnOrder")
    public Map <String, String> addReturnOrder(ReturnOrder returnOrder){
        return returnOrderService.addReturnOrder(returnOrder);
    }

    @GetMapping("/deleteReturnOrderById")
    public Map <String, String> deleteReturnOrderById(int re_id){
        return returnOrderService.deleteReturnOrder(re_id);
    }

    @PostMapping("/selectReturnOrderById")
    public Map<String,Object> selectReturnOrderById(int re_id){
        return returnOrderService.selectReturnOrderById(re_id);
    }

    @GetMapping("/selectReturnOrderByName")
    public Map<String,Object> selectReturnOrderByName(String buyerName){
        return returnOrderService.selectReturnOrderByName(buyerName);
    }

    @PostMapping("/updateReturnOrderById")
    public Map <String, String> updateReturnOrderById(ReturnOrder returnOrder){
        return returnOrderService.updateReturnOrderById(returnOrder);
    }

}
